var mysql = require('mysql');

module.exports=(sql,params=[])=>{
    var connection = mysql.createConnection({
        host: 'localhost',
        user: 'root',
        password: 'root',
        database: '1712a'
    });
    connection.connect((err)=>{
        if(!err){
            console.log('连接成功')
        }else{
            console.log(err,'连接失败111')
        }
        
    });

    return new Promise((resolve,reject)=>{
        connection.query(sql,params, function (error, results) {
            if (error) reject (error);
            resolve(results)
        });
        
        connection.end();
    })
}

 

